package com.cn.lp.ai.factory;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.springframework.ai.qianfan.api.ApiUtils;
import org.springframework.ai.qianfan.api.QianFanApi;
import org.springframework.ai.qianfan.api.auth.AuthApi;
import org.springframework.ai.retry.RetryUtils;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.ResponseEntity;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.ResponseErrorHandler;
import org.springframework.web.client.RestClient;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.util.List;
import java.util.function.Predicate;

public interface CustomerQianFanApiParams {

    @JsonInclude(JsonInclude.Include.NON_NULL)
    record ImageTask(String taskId, String primaryTaskId) {

        public ImageTask(@JsonProperty("taskId") String taskId, @JsonProperty("primaryTaskId") String primaryTaskId) {
            this.taskId = taskId;
            this.primaryTaskId = primaryTaskId;
        }

        @JsonProperty("taskId")
        public String taskId() {
            return this.taskId;
        }

        @JsonProperty("primaryTaskId")
        public String primaryTaskId() {
            return this.primaryTaskId;
        }

    }



    @JsonInclude(JsonInclude.Include.NON_NULL)
    record TextToImageResponse(ImageTask data, String logId) {
        public TextToImageResponse(@JsonProperty("data") ImageTask data, @JsonProperty("log_id") String logId) {
            this.data = data;
            this.logId = logId;
        }

        @JsonProperty("data")
        public ImageTask data() {
            return this.data;
        }

        @JsonProperty("log_id")
        public String model() {
            return this.logId;
        }

    }


    @JsonInclude(JsonInclude.Include.NON_NULL)
    record TextToImageRequest(String text, String resolution, String style, int num, String textContent) {
        public TextToImageRequest(String text) {
            this(text, "640*360", null, 1, null);
        }

        public TextToImageRequest(String text, String resolution) {
            this(text, resolution, null, 1, null);
        }

        public TextToImageRequest(String text, String resolution, String style) {
            this(text, resolution, style, 1, null);
        }

        public TextToImageRequest(String text, String resolution, int num) {
            this(text, resolution, null, num, null);
        }

        public TextToImageRequest(String text, String resolution, String style, int num) {
            this(text, resolution, style, num, null);
        }

        public TextToImageRequest(@JsonProperty("text")String text,
                                  @JsonProperty("resolution")String resolution,
                                  @JsonProperty("style")String style,
                                  @JsonProperty("num")int num,
                                  @JsonProperty("text_content")String textContent) {
            this.text = text;
            this.resolution = resolution;
            this.style = style;
            this.num = num;
            this.textContent = textContent;
        }

        @JsonProperty("text")
        public String text() {
            return this.text;
        }

        @JsonProperty("resolution")
        public String resolution() {
            return this.resolution;
        }

        @JsonProperty("style")
        public String style() {
            return this.style;
        }

        @JsonProperty("num")
        public int num() {
            return this.num;
        }

        @JsonProperty("text_content")
        public String textContent() {
            return this.textContent;
        }

    }

}
